package org.smart4j.chapter1.proxy.dynamicproxy;

import org.smart4j.chapter1.proxy.staticproxy.demo.Hello;
import org.smart4j.chapter1.proxy.staticproxy.demo.HelloImpl;

import java.lang.reflect.Proxy;

/**
 * @ClassName:
 * @Description:
 * @Author: LynnZou
 * @Date: 2017/5/27
 */
public class Main {

    public static void main(String[] args) {
        Hello hello = new HelloImpl();
        DynamicProxy dynamicProxy = new DynamicProxy(hello);

        Hello helloProxy = (Hello) Proxy.newProxyInstance(
                hello.getClass().getClassLoader(),
                hello.getClass().getInterfaces(),
                dynamicProxy);

        helloProxy.say("Jack");
    }
}
